#!/usr/bin/bash

yarn build

#rm -rf ./dist/ue
#rm -rf ./dist/mkt
#rm -rf ./dist/area.js
rm -rf ./dist/index.html.gz

TIME=$(date "+%Y-%m-%d_%H:%M:%S")
FILE_PATH=./dist/$TIME.tar
TARGET_PATH=./dist/*
tar cf $FILE_PATH $TARGET_PATH

ROOT_PATH=/www/wwwroot/www.yakir.cn/
HOST=www.yakir.cn

scp $FILE_PATH root@$HOST:$ROOT_PATH
ssh root@$HOST "tar -xvf $ROOT_PATH/$TIME.tar -C $ROOT_PATH"
ssh root@$HOST "cp -rf $ROOT_PATH/dist/* $ROOT_PATH"
ssh root@$HOST "rm -R $ROOT_PATH/dist"
ssh root@$HOST "rm $ROOT_PATH/$TIME.tar"

rm -rf ./dist/$TIME.tar
